package org.four.merchant.mapper;

import org.apache.ibatis.annotations.*;
import org.four.common.model.*;

import java.util.List;

@Mapper
public interface MerchantMapper {

    //登陆：查看账号
    @Select("select * from t_com_user where userName = #{value} or tel = #{value}")
    ComUserBean findUserInfoByAccount(String userName);

    //注册
    @Insert("insert into t_com_user(userName,passWord) values(#{userName},#{passWord})")
    void regedit(ComUserBean comUserBean);

    //完善信息:修改回显数据
    @Select("select * from t_com_user where id = #{value}")
    ComUserBean addDatum(Integer id);

    //账号信息
    @Select("select * from t_com_user where id = #{value}")
    List<ComUserBean> companyMessage(Integer id);

    //完善信息:修改保存数据
    @Update("update t_com_user set comName=#{comName},address=#{address},zhiZhao=#{zhiZhao},zhiZhaoHao=#{zhiZhaoHao}")
    ComUserBean savCompanyMessage(ComUserBean comUserBean);

    //修改密码
    @Update("update t_com_user set password = #{md532} where id = #{id}")
    void editPassWord(@Param("id") Integer id, @Param("md532")String md532);

    //公司：账户查询
    @Select("select * from t_com_tel where comId = #{value}")
    List<ComTel> findCompanyAccoumt(Integer id);

    //公司:绑定账号修改 回显
    @Select("select * from t_com_tel where comId = #{value}")
    ComTel findAccountById(Integer id);

    //公司:新增 绑定账号
    @Insert("Insert into t_com_tel (tel,email,comId) values (#{tel},#{email},#{comId})")
    void saveCompanyAccount(ComTel comTel);

    //公司:绑定账号修改
    @Update("update t_com_tel set tel = #{tel},email = #{email} where id = #{id}")
    void updateCompayAccount(ComTel comTel);

    //查询公司信息
    @Select("select * from t_com_ziliao where comId = #{value}")
    List<CompanyMessage> findConypanyMessage(Integer id);

    //修改信息：回显
    @Select("select * from t_com_ziliao where comId = #{value}")
    CompanyMessage findCompanyMessageById(Integer id);

    //新增公司信息
    @Insert("insert into t_com_ziliao(touch,tel,email,touchQq,comInfo,comId,comxingzhi,address,hangye,comguimo,licheng) " +
            "values(#{touch},#{tel},#{email},#{touchQq},#{comInfo},#{comId},#{comxingzhi},#{address},#{hangye},#{comguimo},#{licheng})")
    void saveCompanyAccountMessage(CompanyMessage companyMessage);

    //修改公司信息
    @Update("update t_com_ziliao set touch=#{touch},tel=#{tel},email=#{email}," +
            "touchQq=#{touchQq},comInfo=#{comInfo},comxingzhi=#{comxingzhi},address=#{address}, " +
            "hangye=#{hangye},comguimo=#{comguimo},licheng=#{licheng} where id = #{id}")
    void updateCompanyAccountMessage(CompanyMessage companyMessage);

    //公司：绑定账号修改（同步）
    @Update("update t_com_user set tel = #{tel} where id = #{id}")
    void updateAccount(ComUserBean comUserBean);

    //查询套餐条数
    @Select("select count(1) from t_pingtai_package")
    Integer findCount();

    //查询套餐信息
    @Select("select * from t_pingtai_package LIMIT #{start},#{end}")
    List<TaoCanBean> findTaoCan(@Param("start") int start, @Param("end") int end);


}
